/*
 * Simple.h
 *
 *  Created on: Aug 22, 2011
 *      Author: erudhes
 */
#ifndef MAIN_PANEL_H_
#define MAIN_PANEL_H_
#include <wx/wx.h>
#include "MainFrame.h"
#include "SmartPointer.h"

class IGameController;

class MainPanel : public wxPanel
{
	public:
		MainPanel(wxFrame* parent);
		virtual ~MainPanel();
		void onMouseDown(wxMouseEvent& mouseEvent);
		void onMouseUp(wxMouseEvent& mouseEvent);
		void onMouseMotion(wxMouseEvent& mouseEvent);
		void onPaint(wxPaintEvent& paintEvent);
		bool hostNew(const wxString& level);
		bool joinNew(const wxString& host, int port);
		void configurationChange();
		void kickOffClient();
		void finish();
		void restart();
		IGameController* getGameController();
		// Overwrite some inherited methods
		void SetClientSize(int width, int height);
		void SetClientSize(const wxSize& size);
		void SetClientSize(const wxRect& rect);

	private:
		SmartPointer<IGameController> mGameController;

		DECLARE_EVENT_TABLE()
};

inline IGameController* MainPanel::getGameController()
{
	return mGameController;
}

inline void MainPanel::SetClientSize(int width, int height)
{
	static_cast<MainFrame*>(this->GetParent())->onMainPanelClientSizeChange(wxSize(width, height));
	this->wxPanel::SetClientSize(width, height);
}

inline void MainPanel::SetClientSize(const wxSize& size)
{
	this->SetClientSize(size.x, size.y);
}

inline void MainPanel::SetClientSize(const wxRect& rect)
{
	this->SetClientSize(rect.width, rect.height);
}

#endif /* MAIN_PANEL_H_ */
